<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = []
        for (let i = 0; i < 100000; i++) {
            arr[i] = i
        }
        //let arr1 = JSON.parse(JSON.stringify(arr))
        //let num = Math.max(...arr)
        let newArr = []
        console.time()
        for (let i = 0; i < 10; i++) {
            let num = Math.max(...arr)
            let index = arr.indexOf(num)
            arr.splice(index, 1)
            newArr.push(num)
        }
        console.timeEnd()

        console.log(newArr)
        // console.time()
        // let newarr1 = arr1.sort((a, b) => {
        //     return b - a
        // }).slice(0, 10)
        // console.log(newarr1)
        // console.timeEnd()
    </script>
</body>

</html>